import React from "react";
import { Image } from "antd-mobile";
import { Link } from "react-router-dom";
import PropTypes from "prop-types";
import './less/NewsItem.less'

const NewsItem = function NewsItem(props) {
    if (!props.info) return null;
    let { id, title, hint, images, image } = props.info;
    if (!images) images = [image];
    if (!Array.isArray(images)) images = [""];
    return <div className="news-item-box">
        <Link to={`/detail/${id}`}>
            <div className="content">
                <h4 className="title">{title}</h4>
                <p className="author">{hint}</p>
            </div>
            <Image src={images[0]} lazy />
        </Link>
    </div>
}

NewsItem.defaultProps = {
    info: null
}
NewsItem.propTypes = {
    info: PropTypes.object
}

export default NewsItem;